//1-1
val nums:List[Int]=1::2::3::Nil
println(nums)

val nums1:List[Int]=4::5::6::Nil
println(nums1)

val nums2=nums:::nums1
println(nums2)

val nums3=List.concat(nums,nums1)
println(nums3)

println(nums2.filter(x=>x%2==0))
println(nums2.map(x=>x*3))
println(nums2.append(1))  //会报错


//1-2
import scala.collection.mutable.ListBuffer
object Test {
  def main(args: Array[String]): Unit = {
    val nums = ListBuffer[Int](1,2,3)
    println(nums)
	nums += 4
	println(nums)
    val nums1 = new ListBuffer[Int]
    println(nums1)
    nums1.append(5)
    println(nums1)

    //将nums1中的元素追加到nums中
    nums ++= nums1
	println(nums)

    //将nums 和 nums1合并成一个新的ListBuffer
    val nums2 = nums ++ nums1
    println(nums2)

    //将元素追加到nums的后面生成一个新的集合
    val nums3 = nums :+ 5
    println(nums3)
  }
}

//2-1
//不可变
val set=Set(1,2,3)
println(set)
//可变
import scala.collection.mutable.Set
val mutableSet=Set(1,2,3)
println(mutableSet)

//2-2
//唯一性，打印结果为1,2
val set=Set(1,2,2)
println(set)

//2-3
//增加删除实验
import scala.collection.mutable.Set
val mutableSet=Set(1,2,3)
println(mutableSet)
mutableSet.add(4)
mutableSet.remove(1)
println(mutableSet)   //结果为2,3,4
mutableSet+=5
println(mutableSet)  //结果为5,2,3,4
mutableSet-=5
println(mutableSet)  //结果为2,3,4

//3-1
val t=new Tuple3(1,3.14,"a")
println(t)

//3-2
//下标
println(t._1)
println(t._2)
//迭代器
val map1=Map("a"->1,"b"->2,"c"->3);
val iterator=map1.iterator;
while (iterator.hasNext){
   val ele=iterator.next();
   println("key:"+ele._1+";value:"+ele._2);

//4-1:不可变
val map1=Map("a"->1,"b"->2,"c"->3)
println(map1)

//4-2:可变
import scala.collection.mutable.Map
val map2=Map("a"->1,"b"->2,"c"->3)
println(map2)
map2+=("d"->4)
println(map2)

//5-1:Int
val num:List[Int]=List(1,2,3,4,5,6,7,8,9,10)
println(num)
println(num.groupBy(x=>x%2==0))

//5-2:String
val abc:List[String]=List("a","b","c")
println(abc)
println(abc.groupBy(x=>x=="a"))